from pymongo import MongoClient
import statistics
client = MongoClient(port=27017)
db=client['tiktok']
collist=['sfxmakeup','WeekendVibes']

#for col in db.list_collection_names():
for col in collist:
    print(col)
    for obj in db[col].find():
        l=len(obj['text_feature']['stickerText'])
        if l!=0:
            avgl=0
            for t in obj['text_feature']['stickerText']:
                avgl+=len(t.split(' '))
            avgl=avgl/l
        else:
            avgl=0
        db[col].update_one({'_id': obj['_id']}, {'$set': {'video_feature.editing.sticker_num': l,'video_feature.editing.avg_sticker_length':avgl}})
